import Konva from "konva";
import { Draw } from "../../../Draw/Draw";
import { setLineSelected } from "./line-selected";
import { IKonva } from "../../../Interface/IKonva";

/**
 * 线段 单击事件 - 显示锚点
 *  锚点来自于 points 的坐标点解析
 * @param e
 * @param draw
 */
export function lineClick(e: IKonva.Event, draw: Draw) {
  e.cancelBubble = true;

  draw.clearLineControl();
  draw.clearTransformer();
  draw.clearSelected();

  // 2. 拿到线段
  const line = <Konva.Line>e.currentTarget;

  // 3. 设置选中状态（显示锚点）
  setLineSelected(line, draw);
}
